import "../../g_vars";
import express from 'express';
const router = express.Router();

import storage from "../../db/index";

router.get('/dwan', async function (req, res, next){

    const dBackTestKlines = storage.getBackTestKlines('1d-wan');
    if (dBackTestKlines) {
        let data =await  dBackTestKlines.getKlinesByFilter({},{openTime:1, closePrice:1,  _id:0, LEMA:1, SEMA:1})
        let rawdata =  JSON.parse(JSON.stringify(data))

        res.send(rawdata);

    }else{
        res.send("dBackTestKlines is wrong");
    }
})
router.get('/', async function (req, res, next){
    res.render('backtest');
})

router.get('/ema3', async function (req, res, next){

    const dBackTestKlines = storage.getBackTestKlines('1d-wan');
    if (dBackTestKlines) {
        let data =await  dBackTestKlines.getKlinesByFilter({},{openTime:1, closePrice:1,  _id:0, lEma:1,  mEma:1,sEma:1})
        let rawdata =  JSON.parse(JSON.stringify(data))

        res.send(rawdata);

    }else{
        res.send("dBackTestKlines is wrong");
    }
})

export default router;